dim app,doc,v
set app=application
set doc=app.activedocument
set v = doc.ActiveView
main
sub main
	dim ws : set ws = CreateObject("WScript.Shell")
	dim varName : varName = "PADS_SHORTCUT_ROOT"
	dim regPath : regPath ="HKEY_CURRENT_USER\Software\MyApp\PADS\" & varName
	dim varValue : varValue = ws.RegRead(regPath)
	dim ocmd
	ocmd = "cscript """ & varValue & "\skill\includes\rnd.vbs"""	
	ws.run ocmd, 0, False
	varName = "Rnd"
	regPath ="HKEY_CURRENT_USER\Software\MyApp\PADS\" & varName
	varValue =ws.RegRead(regPath)
	set ws = nothing
	dim selectColorIndex
	selectColorIndex = varValue	
	
	Application.StatusBarText = "Set ColorIndex = " & selectColorIndex
	dim ncount
	dim objs
	set objs = doc.getobjects(2,,true)
	ncount = objs.count
		
	dim ostr
	ostr = "Application.ExecuteCommand(""View Nets"")" & chr(13) & chr(10)
	ostr = ostr & "ViewNetsDlg.SelectBy = ""Selected""" & chr(13) & chr(10)
	for i= 0 to ncount-1	
		ostr = ostr & "ViewNetsDlg.ViewList.Selected("& cint(i) &") = true" & chr(13) & chr(10)
		ostr = ostr & "ViewNetsDlg.ColorsButtonPad.SetActive ("& cint(selectColorIndex) &")" & chr(13) & chr(10)
	next			
	ostr = ostr & vbcrlf & "ViewNetsDlg.Ok.Click()"			
			
	dim tmpfile
	tmpfile = doc.path & "\tmp1.mcr"
	Dim fso,fw
	Set fso = CreateObject("scripting.filesystemobject")
	Set fw = fso.CreateTextFile(tmpfile,True)
	fw.Write ostr
	fw.close
	Set fw = Nothing	
	Set fso = Nothing			
	application.RunMacro(tmpfile,"")
end sub

